<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/WEB-INF/jsp/common/taglibs.jsp" %>
<html>
<body class="no-skin">
    <table width="100%" border="0">
        <tr>
            <td width="9%" align="right" nowrap="nowrap"><strong>员工姓名：</strong>
                <input type="hidden" id="orgCode" value="${orgCode}">
            </td>
            <td width="22%"><input name="userName" type="text" id="userName" maxlength="100"/></td>
            <td align="right" nowrap="nowrap"><strong>状态：</strong></td>
            <td align="left" nowrap="nowrap">
                <select name="select" id="status">
                    <option selected="selected" value="">全部</option>
                    <option value=1>启用</option>
                    <option value=0>停用</option>
                </select>
            </td>
            <td width="39%">
                <button class="btn btn-sm btn-info" type="button" onclick="initTable();">
                    <i class="ace-icon glyphicon glyphicon-search bigger-110"></i>查 询
                </button>
                <button class="btn btn-sm btn-warning" type="button" onclick="toAddUser();">
                    <i class="ace-icon glyphicon glyphicon-plus bigger-110"></i>新 增
                </button>
            </td>
        </tr>
    </table>
    <!--查询区域end-->
    <div id="faq-tab-1" class="tab-pane fade in active">
        <!--查询结果-->
        <div style="overflow-x:auto;  margin-top:10px">
            <table id="user_list_table" class="table table-striped table-bordered table-hover" style="margin:0; ">
                <caption></caption>
                <thead>
                <tr>
                    <th nowrap="nowrap" class="center"> 序号</th>
                    <th nowrap="nowrap"> 用户名</th>
                    <!--<th nowrap="nowrap">工号</th>-->
                    <th nowrap="nowrap">员工姓名</th>
                    <th nowrap="nowrap">部门</th>
                    <th nowrap="nowrap">邮箱</th>
                    <th nowrap="nowrap">状态</th>
                    <th nowrap="nowrap">操作</th>
                </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
    </div>

    <script type="text/javascript">
        jQuery(function ($) {
            initTable();
        });
        function initTable() {
            $("#user_list_table").dataTable().fnDestroy();
            json = {};
            json.showLineNuber = true;
            json.id = "user_list_table";
            json.url = contextPath + '/auth/user/getListData.json';
            json.param = [{"name": "orgCode", "value": $("#orgCode").val()},
                {"name": "userName", "value": $.trim($("#userName").val())},
                {"name": "status", "value": $("#status").val()}
            ];
            json.columns = [{"sWidth": "40px", "sClass": "text-center"},
                {"mData": "loginId", "sWidth": "80px", "sClass": "text-center"},
                <%/*{"mData": "agentNo", "sWidth": "100px", "sClass": "text-center"},*/%>
                {"mData": "userName", "sWidth": "100px", "sClass": "text-center"},
                {"mData": "deptName", "sWidth": "100px", "sClass": "text-center"},
                {"mData": "email", "sWidth": "100px", "sClass": "text-center"},
                {
                    "mData": "status", "sWidth": "80px", "sClass": "text-center",
                    "mRender": function (data, type, row) {
                        if (data == 1) {
                            return '启用';
                        } else if (data == 0) {
                            return '停用';
                        } else {
                            return '锁定';
                        }
                    }
                },
                {
                    "mData": "userId", "sWidth": "100px", "sClass": "text-center",
                    "mRender": function (data, type, row) {
                        if (data) {
                            return '&nbsp;&nbsp;<a style="color:#428bca" href="'+contextPath+'/auth/user/toEditUser.htm?module=editUser&orgCode=${orgCode}&userId='
                                    +data+'" >修改</a>';//<%/*&nbsp;&nbsp;<a style="color:#428bca" href="javascript:toDeleteUser(' + data + ')" >删除</a>&nbsp;&nbsp;';*/%>
                        }
                    }
                }
            ];
            var oTable1 = TableManaged(json).init();
        }

        function toAddUser() {
            var orgCode = $("#orgCode").val();
            window.location.href = contextPath + "/auth/user/toAddUser.htm?module=addUser&orgCode=" + orgCode;
        }

        function toDeleteUser(userId) {
            $.Confirm('请确认是否删除该用户？', '', function () {
                deleteUser(userId);
            });
        }

        function deleteUser(userId) {
            $.ajax({
                url: contextPath + "/auth/user/deleteUser.json",
                type: "post",
                data: {userId: userId},
                async: false,
                success: function (data) {
                    var msg = eval("(" + data + ")");
                    $.Alert(msg.message, '', toUserList);
                },
                error: function () {
                    //$.Alert("服务异常，请稍后尝试！");
                }
            });
        }

        function toUserList() {
            var orgCode = $("#orgCode").val();
            location.href = "../../auth/user/toUserList.htm?orgCode=" + orgCode;
        }

    </script>
</body>
</html>
